package vaani.internal.application;

import java.io.File;
import java.util.List;

/**
 *
 * @author sourcemorph
 */
public class Index {

    File dotDesktopFile;
    String name;
    String genericName;
    String comment;

    public Index(File dotDesktopFile, String name, String genericName, String comment) {
        this.dotDesktopFile = dotDesktopFile;
        this.name = name;
        this.genericName = genericName;
        this.comment = comment;
    }

    public double match(List<String> query) {
        if(query.size() == 0) {
            System.out.println("empty query");
            return 0.0;
        }
        double hits = 0.0;
        for(String s : query) {
            s = s.toLowerCase();
            if(name.contains(s) || genericName.contains(s) || comment.contains(s)) {
                hits += 1.0;
            }
        }
        return (hits/(double)query.size());
    }

    public String getDotDesktopFile() {
        return dotDesktopFile.toString();
    }

    public String getName() {
        return name;
    }
}
